//
//  Constants.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/1.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "Constants.h"

@implementation Constants
+(NSString *) apiWithKey:(NSString *)key{
    NSDictionary *dic = @{
                          
                          // 注册登录页
                          
                          @"app_registryCheckCaptcha"        : @"/application/captcha",                  // 2.1 注册一 短信验证码
                          @"app_registryCheckMobile"         :@"/application/registryCheckMobile",       //2.2 注册一 第一步
                          @"app_registryRegistry"            :@"/application/registry",                  //2.3 注册二 第二步
                          @"app_login"                       :@"/application/login",                     //2.4 登录
                          @"app_restPassword"                :@"/application/resetPassword",             //2.5 重置密码
                          @"loginout_authtoken"              :@"/application/loginout",                 //2.6 登出
                          
                          //首页
                          @"home_pagedOrdersInProgress"      :@"/home/pagedOrdersInProgress",          //报修单列表 首页表格订单
                          @"home_pagedOrdersCompleted"       :@"/home/pagedOrdersCompleted",          //报修单列表 分页查询已完成的订单历史订单
                          @"home_pagedOrdersByState"         : @"/home/pagedOrdersByState",           // 根据状态查询

                          @"warninglist_orderList"           :@"/warninglist/orderList",                 //3.1 报修单列表
                          @"warninglist_orderStateFlow"      :@"/warninglist/orderStateFlow",            //3.2 订单详情页——状态
                          @"warninglist_orderContent"        :@"/warninglist/orderContent",              //3.3 订单详情页——内容
                          @"warninglist_orderMessageBoard"   :@"/warninglist/orderMessageBoard",         //3.4 订单详情-留言板
                          @"warninglist_machineRepairList"   :@"/warninglist/machineRepairList",         //3.5 设备维护记录
                          //采购单
                          @"purchase_create"                 :@"/purchase/create",                       //创建采购单
                          @"purchase_confirm"                :@"/purchase/confirm",                      // 确认(拒绝)采购
                          @"purchase_list"                   :@"/purchase/list",                         // 订单详情-采购单
                          @"purchase_listAllFlatten"         :@"/purchase/listAllFlatten",                // 订单详情-所有采购单

                          //设备
                          @"machine_machineInput"            :@"/machine/machineInput",                  //3.6	新录入设备
                          @"machine_machineInputNoOrder"     :@"/machine/machineInputNoOrder",            //3.6	新录入设备（扫码无需报修）
                          @"machine_machineLink"             :@"/machine/machineLink",                      //关联设备
                          @"machine_machineUnLink"           :@"/machine/machineUnLink",                    //解除关联设备
                          @"machine_queryPage"               :@"/machine/queryPage",                    //搜索设备


                          @"warninglist_getQiniuInfo"        :@"/warninglist/getQiniuInfo",              //3.6 获取七牛云存储信息
                          @"warninglist_getProInfo"          :@"/warninglist/getProInfo",               //3.7获取运维人员信息
                          @"location_sharedLocation"         :@"/location/sharedLocation",              //3.9共享定位信息

                          @"warning_heartbeat"               :@"/warning/heartbeat",              //4.12 心跳请求 用来判断用户状态是否正常
                          @"appversion_showProVersion"       :@"/appversion/showProVersion",          //获取APP版本号（proAPP）

                          
                          //报修流程
                          @"warning_orderApply"               :@"/warning/orderApply",                    //4.1 用户发起报修
                          @"warning_orderCancel"              :@"/warning/orderCancel",                   //4.2 用户取消报修
                          @"warning_orderTake"                :@"/warning/orderTake",                     //4.3 维修人员接单
                          @"warning_orderRefer"               :@"/warning/orderRefer",                    //4.4 维修人员转介
                          @"warning_orderProcessByPro"        :@"/warning/orderProcessByPro",             //4.5 维修人员现场处理
                          @"warning_orderProcessByProRemote"  :@"/warning/orderProcessByProRemote",        //4.6 维修人员远程处理
                          @"warning_orderSuspend"             :@"/warning/orderSuspend",                   //4.8 维修人员挂起
                          @"warning_orderRecoveryByPro"       :@"/warning/orderRecoveryByPro",              //4.9 维修人员恢复
                          @"warning_orderRecoveryByUser"      :@"/warning/orderRecoveryByUser",             //4.10 客户确定恢复
                          @"warning_orderCompleted"           :@"/warning/orderCompleted",                  //4.11 维修人员完成
                          @"warning_orderEvaluated"            :@"/warning/orderEvaluated",                 //4.12 客户评价
                          @"warning_orderMessageBoard"         :@"/warning/orderMessageBoard",              //4.13 回复留言板
                          
                          
                          //账号信息页
                          
                          @"reviseaccount_selectCustomer"       :@"/reviseaccount/selectCustomer",       //5.1 显示账号信
                          @"reviseaccount_mobileCheckPwd"       :@"/reviseaccount/mobileCheckPwd",       //5.2 修改手机号码
                          @"reviseaccount_revisePassword"       :@"/reviseaccount/revisePassword",       //5.3 修改密码
                          @"reviseaccount_saveHeadImg"          :@"/reviseaccount/saveHeadImg",        //5.4 修改头像
                          @"customer_getQrCode"                 :@"/customer/getQrCode",          //返回生成二维码所需字符串
                          @"customer_scanCode"                 :@"/customer/scanCode",          //根据二维码获取运维人员信息


                          
                          //银行单位
                          @"select_showBankSelect"              :@"/select/showBankSelect",              //6.1 银行下拉框
                          @"select_showAreaSelect"              :@"/select/showAreaSelect" ,             //6.2	省市下拉框
                          @"select_showEquipSelect"             :@"/select/showEquipSelect" ,             //6.3	设备下拉框
                          @"select_showFaultTypeSelect"         :@"/select/showFaultTypeSelect" ,        //6.4故障类型下拉框
                          @"select_showInstSelect"              :@"/select/showInstSelect" ,             //6.5 机构下拉框
                          @"select_showCommonInstSelect"        :@"/select/showCommonInstSelect" ,       //6.6 常用机构下拉框
                          @"select_showDiscussionKindSelect"    :@"/select/showDiscussionKindSelect" ,   //6.7 讨论贴类型下拉框
                          @"select_showServiceSelect"            :@"/select/showServiceSelect" ,         //6.8	所属服务商下拉框


                          
                          //二维码
                          @"machine_detail"                      :@"/machine/detail" ,                  //7.2	设备信息
                          @"machine_machineEdit"                   :@"/machine/machineEdit" ,               //7.3 设备信息的修改
                          //讨论区
                          @"discuss_list"                        :@"/discuss/list" ,                   //8.1 主题贴分页查询
                          @"discuss_replyList"                      :@"/discuss/replyList" ,                  //8.2 主题贴详情
                          @"discuss_create"                      :@"/discuss/create" ,                  //8.3 创建新主题
                          @"discuss_reply"                       :@"/discuss/reply" ,                   //8.4 创建回复
                          @"discuss_thumb"                       : @"/discuss/thumb",                   // 8.5 点赞
                          @"discuss_unthumb"                     : @"/discuss/unthumb",                 // 8.6 取消点赞
                          @"discuss_listontop"                   : @"/discuss/listontop",            // 8.7 置顶贴列表
                          @"discuss_replyListHot"                : @"/discuss/replyListHot",         // 8.8 主题贴热门回复
                          @"discuss_detail"                      : @"/discuss/detail",               // 8.9 贴子的详情
                          
                          //	消息通知
                          @"message_showAllNotify"               : @"/message/showAllNotify",         // 9.1消息通知首页
                          @"message_showSystemNotify"            : @"/message/showSystemNotify",      // 9.2系统消息通知
                          @"message_showTaskNotify"              : @"/message/showTaskNotify",        // 9.3任务状态变更通知
                          @"message_showReplyNotify"             : @"/message/showReplyNotify",       // 9.4留言回复通知
                          @"message_showDiscussionNotify"        : @"/message/showDiscussionNotify",   // 9.5讨论回复通知
                          @"message_showEmergencyNotify"         : @"/message/showEmergencyNotify",      // 应急通知

                          
                          @"message_doSingleRead"                : @"/message/doSingleRead",          // 9.6 单笔已读
                          @"message_doAllRead"                   : @"/message/doAllRead",             // 9.7 全部已读
                          @"home_orderInfo"                      : @"/home/orderInfo",                // 判断是报修单还是巡检单
                          @"warninglist_getOrderInfo"            : @"/warninglist/getOrderInfo",      // 请求warningUuid
                          @"emergency_getEmergencySignInDetail"  : @"/emergency/getEmergencySignInDetail",      // 签到详情
                          @"emergency_signIn"                    : @"/emergency/signIn",             // 运维师傅签到
                          @"emergency_getUserSignInDetail"       : @"/emergency/getUserSignInDetail",           // 运维师傅签到详情接口


                          @"emergency/signIn"                    : @"emergency/signIn",     //运维师傅签到
                          
                           //巡检单
                          @"inspection_createAndStart"           : @"/inspection/createAndStart",         // 创建巡检单
                          @"inspection_accept"                   : @"/inspection/accept",             // 接单被分配的巡检单    接单
                          @"inspection_transfer"                 : @"/inspection/transfer",           // 转介待处理的巡检单，回退到待分配状态  转介
                          @"inspection_start"                    : @"/inspection/start",               //开始巡检单  开始
                          @"inspection_pagedOperationst"         : @"/inspection/pagedOperations",       // 巡检单操作历史 进度
                          @"inspection_getReportSummary"         : @"/inspection/getReportSummary",    //查看巡检报告-概览 判断是否填完 能不能生成
                          @"inspection_updateReport"             : @"/inspection/updateReport",       // 填写巡检单
                          @"inspection_getReport"                : @"/inspection/getReport",          // 查看巡检报告 全部报告的数据
                          @"inspection_getSubReport"             : @"/inspection/getSubReport",       // 查看巡检报告 按类别 表格
                          @"inspection_getSuggestion"            : @"/inspection/getSuggestion",       // 查看巡检建议
                          @"inspection_createReport"             : @"/inspection/createReport",       // 生成巡检报告
                          @"inspection_getExceptionReport"       : @"/inspection/getExceptionReport",  // 巡检单报告异常汇总
                          @"inspection_getInfo"                  : @"/inspection/getInfo",        // 查看巡检报告-基本信息
                     
                          //我的录入
                          @"customer_findUser"                   : @"/customer/findUser",              // 根据电话查询用户信息
                          @"customer_findProInSameCity"          : @"/customer/findProInSameCity",     // 查找同服务商、同城师傅
                          @"machine_detail"                      : @"/machine/detail",                 // 设备详细信息 通过id找信息
                          @"warning_createByPro"                 : @"/warning/createByPro",             // 报修补录
                          @"home_pagedOrdersCreatedByMe"         : @"/home/pagedOrdersCreatedByMe",     // 我的录入
                          @"warning_orderCancel"                 :@"/warning/orderCancel",              // 用户取消报修

                          };
    if ([[dic allKeys] containsObject:key]) {
        return [NSString stringWithFormat:@"%@%@", APIURL, dic[key]];
    }else{
        return APIURL;
    }
}

+(NSString *) imgWithKey:(NSString *)key{
    NSDictionary *dic = @{
                          
                          };
    if ([[dic allKeys] containsObject:key]) {
        return [NSString stringWithFormat:@"%@%@", ImgURL, dic[key]];
    }else{
        if ([key hasPrefix:ImgURL] || [key hasPrefix:@"http"]) {
            return key;
        }else{
            return [NSString stringWithFormat:@"%@/%@", ImgURL, key];
        }
    }
}

+(NSString *) urlWithKey:(NSString *)key{
    NSDictionary *dic = @{
                          @"nearby_list"        : @"/app/nearby_list.html",         // 商家列表
         
                          };
    if ([[dic allKeys] containsObject:key]) {
        return [NSString stringWithFormat:@"%@%@", WebURL, dic[key]];
    }else{
        return [NSString stringWithFormat:@"%@%@", WebURL, key];
    }
}

+(NSString *) urlWithKey:(NSString *)key param:(NSDictionary *)param{
    if (param == nil) {
        return [self urlWithKey:key];
    }
    NSMutableString *url = [NSMutableString stringWithFormat:@"%@?", [self urlWithKey:key]];
    NSArray *keys = param.allKeys;
    for (int i = 0; i < keys.count; i ++) {
        [url appendFormat:@"%@=%@%@", keys[i], [CClass encodeString:param[keys[i]]], i == keys.count - 1 ? @"" : @"&"];
    }
    return url;
}

@end
